<template>
  <div>
    列表:{{list}}
    <table border="1" cellpadding="0" cellspacing="0">
      <tr>
        <td>名称</td>
        <td>操作</td>
      </tr>
      <tr v-for="i in list">
        <td>{{i.name}}</td>
        <td><button @click="add">添加</button></td>
      </tr>
    </table>
  </div>
</template>

<script>
export default {
  name: "show",
  data(){
    return{
      list:[{'name':'Mac'},{'name':'Apple'},{'name':'Ipad'}]
    }
  },
  methods:{
    add(){
      alert('添加成功')
      this.$axios.post('/cate/add').then(res=>{
        this.list=res.data.list
      })
    },
    show(){
      this.$axios.get('/cate/show').then(res=>{
        this.list=res.data.list
      })
    }
  },
  mounted() {
    this.show()
  }
}
</script>

<style scoped>

</style>
